feat: automatically obtain TLS certificate for /wss listener#8740
feat: automatically obtain TLS certificate for /wss listener#8740marten-seemann wants to merge 3 commits intomasterfrom
Conversation
lidel
left a comment
There was a problem hiding this comment.
Removing the need for nginx for /wss is a significant improvement!
Can't wait for this to land ❤️
Only one caveat: how does the ACME challenge work next to HTTP gateway?
- When I add
/dns4/example.com/tcp/1234/wsstoAddresses.Swarmwill it temporarily start HTTP listener on/dns4/example.com/tcp/80/for HTTP Challenge?- This may be problematic for go-ipfs users because they already run HTTP server of some sort on ports
80and443(either go-ipfs itself, or a reverse proxy like nginx). - Should we detect when ACME challenge port is taken by something else, and pick some other localhost port + print warning asking user to manually mount
http://127.0.0.1:<alternative-acme-challenge-port>/.well-known/acme-challenge/underhttps://example.com/.well-known/acme-challenge/? This should be an acceptable solution for existing nginx users.- I feel we may need the ability to set
<alternative-acme-challenge-port>via go-ipfs-config for better determinism. - If we can use go-ipfs-config, could we pass static cert and use that instead of ACME?
- I feel we may need the ability to set
- This may be problematic for go-ipfs users because they already run HTTP server of some sort on ports
Yes. The
It it's a Go HTTP server, we could just attach to that one, right? Users could pass their
Yes, let me figure out how to do that with certmagic. |
|
Excited to see this, I was thinking the same a little while back. I was going to help a mate do something like https://words.filippo.io/how-plex-is-doing-https-for-all-its-users/ for his app, and I was wondering if it would be useful for folk to have a cert for, say, I have a proof of concept that uses auth0 to identify you on twitter, you pass the app the TXT challenge so ACME can issue you a cert for say Prior art for just issuing SSL certs for an IP was https://sslip.io/ https://nip.io/ |
|
@thattommyhall take a look at libp2p/go-libp2p#1331. TLDR: I suspect we'll want some mechanism to auto-grant people TLS certs so they can support WSS, but a step at a time especially because a bunch of the issues with granting certs are political rather than technological (e.g. one could easily imagine a world where *.peer.id's cert was secured by the peerID itself rather than some CA... but that's an uphill battle) so it might take some time. Those are some great links though 🙏 |
6589293 to
502c5b6
Compare
502c5b6 to
012b857
Compare
|
@thattommyhall Thank you for these links, those are very interesting reads! It's out of scope for this PR, let's get the simplest option up and running. I updated this PR, mostly to update the dependencies. Big win: It's not necessary any more to add an address to |
caba218 to
c3be8e9
Compare
There was a problem hiding this comment.
That is excellent news! Remaining questions:
- What happens when port
80(?) (used for HTTP-01 challenge) is taken?- log Error and continue without
/wss? (sounds fine for mvp)
- log Error and continue without
- How to support manual key setup?
- The manual setup will be pretty niche and elaborate, so little value in exposing this via config. What if we do the same thing we did for private swarm and if one adds
/dns/example.net/.../wssaddr, check if$IPFS_PATH/example.net.crtand$IPFS_PATH/example.net.keyexist and use them if present? (and if not, do ACME)
- The manual setup will be pretty niche and elaborate, so little value in exposing this via config. What if we do the same thing we did for private swarm and if one adds
c3be8e9 to
3bb2ecf
Compare
293ceaf to
b9f0052
Compare
|
@marten-seemann : I moved this back to draft given feedback from @lidel to incorporate. Pease mark as "Ready for review" when it should be looked at again. Thanks again for doing this - good stuff! |
33fbdbf to
26b8c42
Compare
26b8c42 to
859e648
Compare
With this change, users can easily offer WSS support on their IPFS nodes. libp2p will then use ACME to obtain a TLS certificate for the domain.
Configuration: the user needs to configure a wss listen address in
Addresses.Swarmto enable secure websockets support.In the long term, we might be able to get rid of the
AppendAnnouncesconfiguration, but this will require some refactoring in go-libp2p. go-libp2p is currently super eager to resolve all addresses immediately, but the TLS server in websockets actually needs the FQDN to be able to select the correct certificate.Update 2022-02-21:
Addresses.AppendAnnounceis not needed any more.